<%-- 
    Document   : purchase
    Created on : Apr 16, 2013, 4:47:45 AM
    Author     : lohris
--%>

<%@page import="entity.bean.Seat"%>
<%@page import="entity.bean.Show"%>
<%@page import="entity.bean.Movie"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
        <script>
            $(document).ready(function(){
                $(".seat").click(function(){
                    var $markedSeats = $(".unavailable");
                    var markedSeatString = "";
                    $(this).toggleClass("unavailable");
                    $markedSeats = $(".unavailable")
                    for(var i = 0;i < $markedSeats.size() ;i++)
                    {
                        markedSeatString +=($markedSeats.eq(i).attr("id") + ":");
                    }
                    $("#markedSeat").attr("value",markedSeatString);


                });
            });
            
        </script>
        <style>
            .unavailable
            {
                background-color:black;
            }
        </style>


        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Seating Plan Management</title>
    </head>
    <body>

        <%
            Integer noOfHouse = (Integer) request.getAttribute("noOfHouse");
            Integer noOfCols = (Integer) request.getAttribute("noOfCols");
            Integer noOfRows = (Integer) request.getAttribute("noOfRows");
            Seat[][] seatingPlan = (Seat[][]) request.getAttribute("seatingPlan");
        %>
       
        <div id="container">
            <div id="header">
                <div class="noncontent" id="logo">
                    <span>
                        <img src="image/logo.jpg" width="200" height="200" alt="logo"/>
                    </span>
                </div>

                <div class="noncontent" id="title">
                    <h1>Managing Seat</h1>
                </div>
            </div>

            <div id="body">
                <div id="Menu">

                </div>
                <div id="content">
                    <div id="seatingPlan">

                        <form action="SeatManagement" method="POST">
                            <select name="HouseNo">

                                <% for (int i = 1; i <= noOfHouse; i++) {%>
                                <option value="<%=i%>">House<%=i%></option>
                                <%}%>
                            </select>
                            <input type="submit" value="Change" />
                        </form>

                        <form action="ManageSeat" method="POST">
                            <input id="markedSeat" type="hidden" name="markedSeat" value="" readonly="readonly" />
                            <table border="1">

                                <%for (int i = noOfRows; i > 0; i--) {%>
                                <tr>
                                    <td class="nonseat"><%=(char) (i + 64)%></td>
                                    <%for (int j = noOfCols; j > 0; j--) {%>

                                    <td id="<%=(char)(i+'A'-1)%><%=j%>" class="seat <%if (seatingPlan[i - 1][j - 1].getUnavailability()) {%>unavailable<%}%>"><%if (seatingPlan[i - 1][j - 1].getUnavailability()) {%>X<%} else {%><%=j%><%}%></td>

                                    <%}%>
                                </tr>
                                <%}%>
                            </table>
                            <input type="submit" value="Finish" />
                        </form>
                    </div>
                </div>
            </div>

            <div class="noncontent" id="footer">
                <br/>
                <span id="designer">Designed by - Chris Ng, Lusinda Leung<br/></span>
                <span id="copyright">
                    This web site exists to fulfill the coursework requirement of CS4280. Do not use your real	personal data as input.
                </span>
            </div>
        </div>
    </body>
</body>
</html>
